<template>
  <div class="app-container">
    <div>
      <el-form :inline="true" size="mini" :rules="rules" ref="ruleForm" :model="map">
        <el-form-item label="课程名称:" prop="courseName">
          <el-input  clearable maxlength="81"></el-input>
        </el-form-item>
        <el-form-item label="状态:" prop="courseName">
          <el-input clearable maxlength="81"></el-input>
        </el-form-item>
        <el-form-item label="是否免费:" prop="courseName">
          <el-input clearable maxlength="81"></el-input>
        </el-form-item>
        <el-form-item label="上下架:" prop="courseName">
          <el-input clearable maxlength="81"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" type="primary" clearable maxlength="81">查询</el-button>
          <el-button icon="el-icon-refresh" class="filter-item" clearable maxlength="81">重置</el-button>
          <el-button icon="el-icon-circle-plus-outline" type="primary" clearable maxlength="81">添加</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      stripe
    >
      <el-table-column type="index" align="center" label="序号" width="50">
      </el-table-column>
      <el-table-column label="课程封面" width="200">
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="课程名称" width="200">
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="课程分类" width="600">
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="价格" width="110" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.author }}</span>
        </template>
      </el-table-column>
      <el-table-column label="上下架" width="110" align="center">
        <template slot-scope="scope">
          {{ scope.row.pageviews }}
        </template>
      </el-table-column>
      <el-table-column align="center" prop="created_at" label="状态" width="110">
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.display_time }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="操作" align="center">
        <template slot-scope="scope">
          <el-button>修改</el-button>
          <el-button>章节详情</el-button>
          <el-button>删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getList } from '@/api/table'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null,
      listLoading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      getList().then(response => {
        this.list = response.data.items
        this.listLoading = false
      })
    }
  }
}
</script>
